<template>
  <div>
    <z-table :list="list" :tableProps="tableProps" :columns="columns">
    </z-table>
    <z-pagination :pagination="pagination" :total="total" :page.sync="query.page" :limit.sync="query.size"
      @change="getList"></z-pagination>
  </div>
</template>

<script>
import commonMixin from '@/views/_common/mixin'
export default {
  mixins: [commonMixin],
  name: '',
  components: {},
  props: {
    activeName: {
      type: String,
      default: '',
    },
    DetailedItemNo: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      query: {
        page: 1,
        size: 10,
      },
      // 明细账
      tableProps: {
        border: true,
        opsColWith: 80,
        fixed: false,
        hideOperations: true,
      },
      baseUrl: this.$api.baseUrl,
      columns: [
        { title: '备件编号', key: 'serial_number' },
        { title: '备件料号', key: 'item_no' },
        { title: '入库日期', key: 'create_time' },
        { title: '数量', key: 'qty' },
        { title: '修改人', key: 'modify_user' },
        { title: '最后修改时间', key: 'modify_time' },
      ],
    }
  },
  computed: {},
  watch: {
    activeName: {
      immediate: true,
      handler(val, old) {
        if (val == 'subLedger') {
          this.getPartDetailList(this.DetailedItemNo)
        }
      },
    },
    DetailedItemNo: {
      immediate: true,
      handler(val, old) {
        if (this.activeName == 'subLedger') {
          this.getPartDetailList(this.DetailedItemNo)
        }
      },
    },
  },
  created() {},
  mounted() {},
  methods: {
    getPartDetailList(val) {
      let Data = {
        item_no: val,
        page: this.query.page,
        size: this.query.size,
      }
      this.$request(this.baseUrl + 'Tpm/TpmPartAccount/GetPartDetailList', Data, 'post').then((r) => {
        const { list, total } = r
        this.total = total
        this.list = list
      })
    },
  },
}
</script>

<style lang="less" scoped></style>